package com.learn.springboot;


import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class MyCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        Map<String, Object> map = metadata.getAnnotationAttributes(MyCondition.class.getName());
        String[] values =(String[]) map.get("value");
        boolean flag = true;
        try {
            for (String value : values) {
                Class<?> aClass = Class.forName(value);
            }
        }catch (ClassNotFoundException e){
            flag=false;
        }
        return flag;
    }
}
